How to create a horizontal scrolling level with some depth?

I’ve just started to learn Unreal Engine 4.26.2 and now I’m trying to understand landscapes.

While learning, I have thought about the levels of the games that I know and I’m not sure if these levels were made using one map, and if that is, how big the landscape was be.

I have an idea for a game and I don’t know who big a landscape could be (because in the Unreal documentation suggest the sizes with the best performance. My game will be a 3D horizontal scrolling game with some depth in the background but the character will move only in a 2D plane.

How can I do it?

Without using landscapes.

The world size is not “infinite” unless you use world origin rebasing.
When you do, then the world can pretty much be any size, and also generated procedurally.

For a game where the character has no access to the area of the background, its likely best to use a pre-rendered image background or a small portion made with meshes.

For instance, you could assemble any world you want, take a high-res screenshot in engine that spans whatever pixel width you wish, and use slices of the image as the background for the actual level.
You could even take several shots or assemble the graphics from footage of a panning camera render.

The point is, loading and handing landscapes is a mess to begin with. When there’s no actual need for it, do all you can to avoid it.
A 2.5d game is the perfect use case to use imagery instead of actual components, since with a bit of parallax you’d essentially never be able to tell.

Rayman Legends comes to mind as an example that does this with procedural/tiled backgrounds.

If you want seamless scrolling always, break the levels into logical chunks and stream them in / out.