In the above examples, the outcome is the same. But in the case of the first one, you are using the prev state value explicitly. This is handy in many cases where you use the previous state value to compute and set the current state value.
The prev is guaranteed to have the prev state value, whereas there could be cases that relying on just the counter may not get you the previous state value. It may happen when you update the state on an event(say click event) and the event occurs very fast.
The state update may not happen as expected because the onClick props function creates a closure on the counter value. So if the onClick triggers too fast, the counter value may not get updated constantly as expected. Using the prev state will make sure it does.