Plane rendering through object that is closer to camera

In my game, there are these red blocks that protrude from the grey blocks at random intervals. Behind the grey blocks is a plane that acts as a background. (I chose to use a plane instead of solid colour as it means I can add bloom or whatever later on). The red block is using a URP lit transparent material in order for me to add a fade effect. It appears to be that this issue only occurs with transparent materials. I did change the project to URP from normal 3d which may have affected things, but the materials are all URP materials and I followed all the steps I should take. Here is a picture:

Ok, I fixed it by changing the background material to opaque from transparent. But does this mean I can never have transparent materials in front of each other? Is there another way to solve this issue?