High school mathematics is taught very, very badly. As you say, it tends to just be a case of being shown various formula and told to memorise/use them. Students rarely have any real idea where they come from or why they are true, since this isnt taught. Its a shocking failure of curriculum design. So your lack of understanding isnt your fault, and almost all other students will have the same experience.
In university mathematics things are completely different, and the emphasis is on learning and understanding _why_ things are true, and being able to derive and prove them.