How the lookup works
First the whole callsign is looked up in the exception list. It holds around 23,000 callsigns that do not match their prefix: club stations on an island, stations in special areas, historic assignments. Only if nothing is found there does the longest matching prefix count.
Compound callsigns are taken apart first. In 9M6/LA6VM the first part names the location, in LA6VM/P the first part too: /P, /M, /MM and the like say nothing about the country. A plain digit as in R3RRC/1 is an area within the same country and is dropped.
Two warnings: a DXCC entity is not the same as a state, entities follow the rules of the award, not the map. And the point shown is the centre of the entity, not a station address. For a large country like the USA the bearing is only a rough direction.