Is it true that UE5 can't be used to make a 2D game?
Yes, you can use Unreal Engine 5 for 2D games. A quick search will confirm this and there are also tutorials that will tell you how to do it.
But possible and ease of usage are not necessary the same thing. Any engine that is capable of creating a 3D game can create a 2D game as well. It is just a question of how determined you are.
A few years back, Unity was by default for 3D games. Over the years they got a lot of 2D support. But it was always possible to create 2D games. The new tools just made it easier for creating content, easier/ simpler physics and optimization. This could be a problem for example in mobile builds when the tool is too powerful and you try to fit it.
Choosing the correct engine is not easy. Some people prefer visual scripting/ blueprints. Some just use scripts and not the editor. Some just want to have a lot of options available. When you choose one, a good indicator is how many tutorials are available and how active the community is. If you can't decide between a few, download them all and make a simple game (pong or breakout) in all of them. Compare how easy it was or with what you struggled. If a simple game already is giving you trouble (trouble as in the engine does not want as you want it to be, either not understanding how it works or just interactions), a full blown game like you plan to do will be a nightmare.
In the end you need to be happy with it when you code with it.