For example, I was playing showdown and I had max speed Zacian but I got outsped, how?
If the opponent Pokemon has the same speed as you, there is a 50/50 chance of who will go first, unless one of the Pokemon uses a priority move, or changes form to have higher speed.
Hope this helped!
If there is an exact tie in speed, it's broken randomly each time, and winning a tie last turn has no bearing (positive or negative) on who's going to win it if the same tie crops up again this turn.
Its a 50/50 chance either goes first.
source: experience https://bulbapedia.bulbagarden.net/wiki/Statistic#Speed and https://replay.pokemonshowdown.com/gen8nationaldexag-1133272295