My position is similar to yours. My professors in college were great, but we did not cover everything in-depth. I took Abstract Algebra and Complex Analysis during the fall and spring semesters, respectively, of my senior year as electives since they were only offered every third year. I took them because I thoroughly enjoyed pure math and found the prospect of a semester without a math course to be unacceptable/unfathomable. I had also taken mathematical logic, history of math, and introduction to graph theory; I technically finished all of my math major requirements during Junior year. Since my school was small, the math professors had no time to supervise legitimate independent studies due to their teaching loads. Unlike most of the other math majors at my school, who were really in the math education program, only a very good friend of mine and I wanted to go to graduate school for math. I was fortunate enough to get good recommendation letters for my Masters, but like you, my preparation was poor. I had good grades, but my fellow graduate classmates were mostly top students at tougher schools. I still hate myself for not working harder to transfer to a better undergraduate program, but nothing can be done about that now.
I did a summer program right after graduation, which helped me prepare for the fast-paced rhythm of my Masters courses, but it was still rough. I did learn to acknowledge that taking classes by themselves was insufficient. Graduate school expected a thorough and exhaustive preparation that I did not receive in the classroom; the professors you encounter in graduate courses will not always be good lecturers nor helpful otherwise. Self-teaching is paramount. Although frustrating, reading and rereading sections in a textbook until it all makes sense can be the only way to get through vexing problem sets. Go to all office hours, but don't expect enlightenment all the time. Study groups also may or may not work; I have had mixed results, depending on the goal in mind. Even getting the week's assignment done was a challenge if others in the group had given up. Something else that has helped me cover gaps in my foundation is just reading several textbooks on the same subject, then looking for more information on the internet. This helped me a lot for topology and graduate algebra. The math department's library was quite helpful after a careful Google search. You may be lucky and find rare solutions manuals for advanced textbooks or problem books with worked-out solutions. Redo as many examples as possible; memorize the steps until you fully comprehend the logic and can provide the proof for a similar problem effortlessly. If you have free time and would like to make some extra money, try tutoring math. This will help keep all the basic theorems from lower-division courses fresh in your mind and give you an opportunity to master anything specific you had forgotten or never really got without an instructor or textbook's help or rote memorization when you prepare for sessions. Additionally, when you tutor students from several different schools, you will notice how all the instructors emphasize different topics, methods, and tricks, which you can learn on the spot and add to your repertoire.
Try to adapt, to learn as quick as you possibly can, and to accept that it will take considerable time and effort to catch up to those who had a better classroom preparation at another school. If you can transfer, do so as soon as you can, or audit courses elsewhere, find videos online, and read as many helpful math textbooks (I prefer those with detailed examples) and do as many problems as you can while you still have access to helpful faculty members. Bombard them with questions if you get stuck (when they are not too busy). Also, if your undergraduate adviser is in the math department, set up a meeting. Then, be honest and express your concerns. If nothing insightful is revealed, go back to self-teaching. I also agree with the suggestion about going to an REU; I should have tried to do one every summer. Apply for all the ones that interest you.
By the way, my friend went to get his Ph.D. at a school that did not require the math GRE. He is doing well there. I didn't have a basis for it, but I thought that such a school would be a repeat of our undergraduate program since its admission policy wasn't too strict. He did struggle like I did, but he is a truly stubborn perfectionist who doesn't give up. He is now beginning his dissertation research.
Don't get discouraged; if everything else fails, just be patient and always do your best. Hopefully, you can get into a good graduate program if that is your desire. You may not get your Ph.D. until after your late 20's, but if this is what you want, don't give up, do as much as you can now before you graduate, and steel yourself. The road ahead will be challenging.