Neglected many aspects of knowledge during my PhD research. What's the best strategy to learn and be comfortable in it? My question is very vague. I just realized that there are many aspects of my research field that I have very limited knowledge in but would like to explore as a future research direction. Is it too late or I can use any strategy to gain the knowledge and be in a position to contribute in the field?

I have spent 5 years PhD in an applied field. Publishing in my field of work is not mathematically intensive. It's more of utilizing the tools available for carrying out simulations and analyze the physics of the problem and results.

However, now I am beginning to realize that development of the tools being used in my field (materials science) is much more rewarding in terms of research output, securing a position in a national lab or a tenure track position than just using an open-source software or making minor tweaks to it.

I want to learn the mathematics behind the tools available for my field to such a degree that I can comfortably develop my own code. I have good programming skills. Is this a too far a goal for this stage of my studies? I am about to defend my PhD thesis.

I should have realized this years ago...but here I am. Is this an achievable goal?

Ps: I have an understanding of the mathematics that goes on under the hood of the softwares. But I have never actually coded a simplified version of the tools myself. I self-studied few books to gain some insight on the tools and just leapt in using them to my research.
Actually, your experience is probably (nearly) universal. Doing research requires a deep dive not a broad view. But it also gives you skills. Employ those skills to things that seem "interesting" to you and you will fairly naturally expand the horizon. 

In many fields it is impossible to know everything, as there is too much. Math passed that boundary sometime in the early 20th century. 

Take a long view, assuming that you have suitable employment. Pick a topic that you think would be worth a look, for whatever reason and study it as intensively as you can for some period of time. When you are comfortable with what you have learned or you become bored with it, move on to another. 

Earning a doctorate doesn't mean you have learned everything you will ever learn. Many people even radically change fields after earning a PhD. Many people in one field invent another field. Computer science, for example, grew out of math and engineering.