The limit is restricted to only one faction and occurs on each of their colonies individually. That means you could have 23 divisions on earth, and another 23 divisions on moon and mars, or anywhere, but another faction on earth could have 23 divisions there too no problem.
Remember, the whole problem with this (error windows) only ever arises with the selection of a colony that has more than those 500 battalions active on ground. The real problem therefore is that aurora is incapable of listing more than 500 battalions, which means everything that is not part of the listing is safe. With that it is clear that no amount of enemy or npr troops has any say in this, because there is no option to list their details for the player. Also, you can kind of hide an infinite amount of troops by storing them in pdcs or ships in orbit, as you need to select them in dropdown to be listed. As long as you keep your fingers of the dropdown menu, you are free of errors and unlimited in troops even on a single colony.
(I strongly recommend not to do that on your capital though, as having too many troops is the single responsible issue that slows down the colony-window loadup in later game stages. ...I have moved on to store nearly all my troops on the moon by now for example, so they are close enough to get there in case of probable invasion, but wont obstruct the loadup for 99.9999% of the gametime.
)
Then, it could even be possible to have multiple 23 division assemblies
on ground on the same planet, as long as you have different colonies on it to store them in (through genetic mutation races for example). I have not tested this though, and the window might sum them all up, so it wouldn't work.