I have this recipe that is of the cake family. The base is canola oil and sugar. Whenever I cook this pan in a square glass pan it cooks perfectly. However, when I use metal pan it doesn't cook properly. I don't fully understand why this is.
This is completely normal. The pan stands between the heat source and the cake. It lets through radiation and also conducts heat at different speeds. Also the convection patterns in the oven are changed by the shape of the pan. You cannot predict which pan will speed up or slow down the baking by comparing it to another pan, because the relationships are complex. But you can simply bake a cake and observe both.
As to how to avoid it: baking by time simply makes no sense. It is a coincidence that you have a combination of oven and pan which bakes the cake in exactly the time the author suggested. As you found out, as soon as you change the pan, the time directive doesn't work.
Bake your cakes until they are done. This way they will work in any pan as long as the general height/area ratio is right.