I don't know how to explain this really well, but the rails in Minecraft Bedrock Edition 1.18.12 just aren't working correctly, the rails just don't connect correctly when making a turn to the right and going up at the same time.
It also hasn't been working in the preview version either.