There are numerous number of different engines and frameworks in all of application areas — web development, computer graphics, networking, game development, machine learning, etc. Despite of that more of them are coming every year, and some of them become quite popular.
Many software developers write their own frameworks. Usually they do this because:
They like to do this, oh yeah!
They like to keep things under control. In your own framework you control everything, you know where do things come from and how they're used.
They don't like to mess with other's solutions. Really, it takes time to learn some third party solution, and things aren't always are as you want or expect.
Some of them believe that they do it better than the others. Some of that some really do.
Despite of numerous number of different frameworks still sometimes there is no framework that perfectly fit and cover all of your needs.
So, should you write your own?
Why does anyone need a framework anyway? The best way to understand this is to write some application from scratch without any frameworks, engines or libraries. No matter what kind of application will it be — a website, a game or a server. Doing so you will realize that:
You have to invent many thing by yourself.
You write too much code. You have to write many lines of code to do things that can be expressed in human language in a single sentence.
You have to spend too much time to check things for validity, and if you don't then your application will perform unpredictible, failing into inconsistent state under some special circumstances (that you may don't even know about).
When you change some single thing you need to make changes in many places of your code.
And even if you overcome all that and do well within a single application, eventually you will write some other application and realize that you've could take many things from the previous application instead of inventing them once again.
OK, that explains why you do need a framework. But do you really need to write your own framework? The answer is yes, and here is the list of reasons for that:
The main reason why you should do this is self-development. Frameworks solve problems. Problems of which existence you don't even realize until you write your frameworkless application and your first own framework. Writing your own framework will give you an understanding why do people actually write and use frameworks. And there is a huge difference between reading about the reasons to do so in a book and realizing it on your own experience.
Different frameworks of the same application area solve the same problems. So, a deep understanding of these problems will make it much easier for you to learn any third party framework. You will already know what questions you should ask and what answers you should expect.
In fact, you're almost always write your own framework even when you use some third party solution. However in most cases it is too tiny to be noticed. It's very unlikely that you will create an application just by calling third party functions and instantiating third party classes. Almost always you will write auxiliary classes and functions as well as their composition. These classes and functions are in fact your very own little framework.
It's OK if you won't sell your framework to Google for 10 millions of USD or even if you will be the only user of your solution. Inventing things that are already invented by someone else is an excellent way of self-development. Just don't isolate yourself from the outer world and compare your inventions from time to time with those which are already invented. Ask yourself why have they made same things in a different manner and search for the answer which way was better.
So, should you use your own solutions only?
No. Inventing your own frameworks doesn't mean that you don't have to use third party solutions. You should learn them and you should use them. Sometimes you may be upset of their disadvantages. However any popular framework has advantages that your own probably doesn't:
They write a documentation! Let's be honest. You never write a documentation for you code, don't you?
Popular third party code has a lot of users which means that it is tested much better than your own code. They use it, they find bugs, they fix bugs.
To develop your own framework you actually need to work. You need to spend your own time, you need to do it by your hands. And if you don't — your code stays where it was before. On the other side, you need to do nothing to develop third party code — they will do it for you, and almost always do for free, yay! So you can just continue your work and wait for an update.
I don't know how to invent a framework. What should I do?
The basic idea is: your work should be as easy and comfortable as possible. You should spend your time on inventing and implementing useful things, and this activity should flow in a very convenient manner. The less information you have to hold in mind to keep everything under control — the better. The less actions you have to take to make changes — the better. The more invalid states are handled properly without your direct participation — is also the better.
Don't think about features that your framework should have before you need these features. Start developing some application from scratch. Over time you will start facing problems that break the basic idea I described above. You will get feeling that things could be done in a lesser amount of work. That things could be done once instead of multiple times. That you express your intentions in code not as simple as you've could. Feeling any of these will mean that you've faced a problem. Focus on the solution of this problem. Find this solution. Try to make this solution general so you've could reuse it next time you face the same problem. A collection of such solutions is your very own framework.
Follow some standards or invent your own. It's much easier to remember a standard than remember an unstandardized code or structure.
There are a lot of books about software development and you should read them from time to time. However making your own solutions gives you a unique experience and much deeper understanding of how things do work. Combine these approaches to get the most significant results — invent yours, but don't forget to learn from the others.