The answer is yes, of course, but it is difficult. And if you spread yourself too thin while learning you might not be successful in any field.
The real issue is that to do research in some field of mathematics you need insight, not just knowledge in that field. And insight is expensive and hard to achieve. Some people have deep insight into several areas of math of course. Paul Erdős comes easily to mind, of course.
But that insight doesn't easily transfer from one subfield to another. I once had deep insight into classical real analysis and fairly good insight into general topology. But my insight was almost totally lacking in most of algebra. Especially ring theory.
But, from where you currently sit, I'd suggest that you pick a single (at most two) fields and really seek insight. Mere knowledge isn't enough. It may be enough to tell you why theorem proofs work, but you need insight to be able to propose things that (a) might be non obviously true and (b) worth the effort and time of exploring whether they are indeed true.
Fermat's Last Theorem is a case in point. Whether or not he did have an "elegant" proof, the statement itself was a leap requiring deep insight.
Almost any doctoral program will require you to take a deep dive into a narrow area. In the US, that will be preceded by a broader view of several areas to get you ready for comprehensive exams, but also to help you find that narrow area of research. You will probably need to do that to be successful and even begin a career.
But, once you have a credential and a secure income stream, there is nothing to prevent you from seeking insight into other areas. Your initial specialization will require insight, but it doesn't bind your future. Just don't try to do it all at once, though there are extremely rare exceptions.
In some sense, knowledge tells you what did work. But insight tells you what might work.