matchmaking is based on a glicko ranking system, which determines your internal "power" for each mode (only directly visible in X battle). the specifics of the system are a little too complicated to go into here, but basically it goes up when you win and down when you lose, and the amount is based on the difference between your power and the power of your opponent. when you gain access to different game modes, it copies over your power from another one as a baseline, and then diverges from there.
the reason why you'll see players in different ranks is because matchmaking is only based on power. an A rank player who is performing exceptionally well for their rank could be matched with players in S+, or vice versa.
notably, there is one exception: players above 2k X power will never be matched against players below 2k X power.