I have created 4 custom fields on account, and I want those fields to store the number of opportunities according to their status(e.g. Active, Inactive, Open, Lost). Once the admin creates an Open Opportunity on an Account, the number of Open Opportunities [which is a custom field on Account] should increase. I've tried using Process Builder, Apex classes/triggers and Workflow rules all in futility.
You can use simple roll-up summary fields. Go to the Customize Accounts Fields area in Setup, and create four new roll-up summary fields, one for each status. If you'd like to do this with Apex Code, you should search other questions on this forum that include answers from several sources on how to build a custom roll-up relationship trigger, or consider using the Declarative Roll-Up Summary tool that's already been built.