How do I know what the best number of layers is required to achieve the highest accuracy
The number of layers and the number of nodes in each layer are model hyperparameters that you must specify. So, we cannot directly say this no of hidden layers / this no of hidden units / this learning rate .. are better.  But we can use some techniques :

Intuition:
So based on the complexity of your model, you need to choose a value that you feel suits it the most.

Experiment:
Now, if your intuition fails, then you should experiment and see the nature of the model. So, try to plot the cost function for different values of the hyperparameter and understand the behavior of the model, with which you can probably get the best value for your hyperparameter.


Generally, if your model is expected to learn complex patterns, then you should go for depth.
For no of neurons in a layer, there are some rule-of-thumb methods:

The number of neurons should be between the size of the input layer and the size of the output layer. (or mean of both)
The number of neurons should be : (2/3 the size of the input layer + the size of the output layer)

There are some other rules and formulas, but I think these rules should give you a good start. But still, the key is your intuition and experimentation.