Rails do not connect with each other or allow minecarts to be placed on them if vanilla data pack is disabled.
1. Run /datapack disable vanilla to disable the vanilla data pack.
2. Place some rails beside each other.
3. Try placing a minecart on them.
Edit: Duplicate of