They are used precisely that way in most Japanese titles, but for some reason when Playstation games were localized outside of the Japanese market the baffling decision was made to swap the positions of the OK and cancel buttons. So we got X for OK and O for cancel, which totally makes sense...
I think it was to be similar to the XBox layout. I did wonder why the X was there, but never really asked.
It's interesting because I've just recently learned the Japanese layout on Switch and it's really sticky in my brain to the point that it's taken over, so I've switched over on my PC controllers too. Except now games don't know what to make of it, like Hollow Knight let me remap controls so button 2, which is B and on the bottom, is jump, and button 1 is A and on the right is spell. Now the menus behave the Japanese way, but also the game thinks that A is called B and B is called A because they were remapped and it assumes jump must be A and spell must be B, so now I need to ignore the button prompts in menus.
Also Bopl Battle lets you remap controls, but then it forces jump to be confirm no matter what, so you can have A for confirm and B for back in the main menu, but when you go into the game B becomes confirm and A becomes back. Me and my kids have bounced ourselves out of matches so many times it's infuriating.
IIRC this was originally a Squaresoft decision, and was originally done for ergonomic reasons. Then other publishers started following suit. Square switched from the Japanese style O for OK, X for cancel between Final Fantasy 7 and Final Fantasy 8 in the US. 7 has Japanese style controls, 8 by default has the American style layout. I have never actually seen a definitive explanation given, though.
FWIW, the original Playstation predated the XBox by six years (1995 vs. 2001). The X/O switch for non-Japanese Playstation games was well in effect long before the XBox ever landed on store shelves, so I'm pretty sure the reverse is actually true. The XBox button layout is designed to ape the Playstation's ergonomically, but the letters are shuffled around so it is not the same as the Nintendo/SNES controller most likely for lawsuit avoidance purposes.
Huh, well I was just guessing about the XBox thing to be honest, sounds like you know more about it.
Also the difference between the layouts wouldn't be so infuriating if XBox and Switch didn't have literally the exact opposite in both naming and functionality across both of the X/Y and A/B pairs.
I don't know why though, but I adopt the Switch style much more easily than I flip back. It's weird because the bottom button is always the easiest to press and you'd expect that to be the obvious ergonomic answer, but my brain has some weird preference for the other way.
This has got to settle into a convention sometime. I'd be interested to see if there's any research into it.
Actually, I found this informal poll (in English which would skew the results). In playstation the western style is overwhelmingly favoured but Nintendo and XBox styles are about an even split:
To be fair, I have seen the XBox theory floated repeatedly on the internet, never with any acknowledgement that the timeline doesn't make sense...
Insofar as I can determine from my standpoint of being a video game collector who has no inside knowledge but was at least there at the time, Sony copied the SNES pad when they split from Nintendo after the original Play Station add-on debacle. As a matter of fact, the original original plan was to just use the SNES controller itself to begin with. The button conventions for the subsequent Playstation pad were obviously meant to be a direct copy-paste of the above and intended to be used in the same way as was currently the norm for Japanese console RPG's on Nintendo's machine: A was for OK and B was for cancel/back. The Playstation O button is where the SNES A button is, and the Playstation X button is where the SNES B button is. It all makes sense.
...Until it got switched. Only outside of Japan. For reasons that no one responsible has ever seen fit to document, at least publicly.