It is amazing how much misinformation flies around about guns. One of the common ones is "OMG the M4/16 is such crap, the AK is so much bettar!"
You are quite correct about the range. The AR-15 platform weapons are much more accurate. Anyone who has ever fired both can easily tell that.
The issue that people like the grandparent conflate is the lethality of the 5.56x45mm round at longer ranges. Though the M16 can easily hit a target at long range (with a skilled marksman operating it), because of the small size and low mass of the round, it is often not as effective as you would want. If the bullet does not fragment or tumble, it can go right through someone and the small hole does little damage.
That is the issue it has at range, not accuracy or ability to reach that range.
Also this isn't like it is some completely unknown, or unsolvable, thing. The military also has weapons that use 7.62x51mm rounds which are larger rifle bullets and have much greater range, mass, and kinetic energy. For longer engagements still things like 8.58Ã--70mm and 12.7Ã--99mm are used.
Of course as you move up in caliber and amount of propellant, weapons become bigger and heavier, and have larger amounts of recoil to deal with, it is always a tradeoff and is one reason why the standard personal weapons use 5.56.
In terms of 5.56x45mm vs 7.62Ã--39mm (which is what the AK uses, is is not the same as the larger NATO round) the real issues come up at medium range (100-300m) and with barrier penetration. The light, high velocity 5.56 round tends to be fantastically lethal below 100m because the high velocity results in fragmentation when it hits the target. However since military rounds may not be specifically designed to fragment or expand (the Geneva convention prohibits it, civilian and police rounds are available that do), as it slows down at greater ranges they lose that ability and are not as damaging. Also, because of their low mass and tendency to fragment they are poor performers when shooting through barriers like windshields, doors, and so on.
THAT is the issue the rounds have in general use vs 7.62Ã--39mm rounds. Not long ranges. While they aren't super effective beyond 300m, they are reasonably accurate at least, which is not the case with the 7.62 rounds. At a long range engagement an M4 would be at a decided advantage to an AK-47.
However neither was designed for long range use. They are carbines, made for medium range and below. They trade overall power and range for smaller size, lower weight, and better portability. As their widespread use in many conflicts around the world indicates, they do well in that arena.