Modern consoles work in both orientations, but there are other considerations.
For the most part, modern consoles are fine parked either vertically or horizontally. All PlayStation 5 models, as well as both the Xbox Series X and Series S, were designed to work in either orientation. Thus, you can choose based on available space and how you want everything to look.
The factor to consider is airflow, since consoles need room to breathe. Keeping your hardware healthy for a long time is especially important now that console prices are constantly going up.
For reasons, you shouldn't wedge a PS5 or Xbox Series X/S into a tightly enclosed media cabinet or stack other devices on top of it. Neither console should be placed right against walls, and you should never wait until you need an industrial vacuum to out the dust.
Before deciding, look at the vent places and the surrounding furniture or shelf space. If laying it down or standing it up blocks an intake or exhaust, do the opposite. Outside of those cautionary tidbits, the specifics come down to your situation.
The practical differences mostly concern stability and which console you own. Vertical generally saves space and is useful in a narrow entertainment center or if your gaming area is crowded. If you have rowdy dogs or adventurous children, a vertical placement might be asking for trouble.
Using the stand included with the PS5 and Series X will help, but it's not a solution for sugar-fueled kids.
The small advantage of horizontal here is that it's easier to remember which way the disc goes compared to vertical.