First of all both underfitting and overfitting are not good characteristics of a machine learning model. So we go for Best Fit which falls somewhere between underfitting and overfitting.

In the above mentioned diagram the model is very loose fit or under fit to the data points(dots on graph). Here the model is getting in touch with a very low count of data points. Lets understand it with an example, Lets say we trained a model to identify a ball and for that we provided it with only one attribute which is shape i.e. if shape of object is sphere then only the model can say it is a ball. But now for testing I provide a orange whose shape will also be sphere, So the model will identify it as ball. So here we are trying to be more general by providing just the shape information.

In the above mentioned diagram the model is trying to over fit the data points(dots on graph). Here the model is getting in touch with every data point possible. Lets understand it with an example, Lets say we trained a model to identify a ball and for that we provided it with attributes such as shape, can play with it or not, can eat it or not, radius=5cm. But now for testing the model I provide a ball itself of radius=10cm, Now here the ball satisfy the first 3 conditions – shape=sphere, can play with it, cannot be eaten but the last one is not satisfied as the radius=10. Hence the model says it is not a ball, which is a wrong prediction. So here we are trying to be more specific with the information that we are providing to the model.