An action done out of forgetfulness does not invalidate the fast; an action done due to a mistake (poor judgment) does invalidate the fast depending on the circumstance.
If for example, a fasting person makes the false assumption that maghreb has arrived without verifying it and ends up breaking their fast 15 minutes or so before maghrib time, then this is considered a mistake that would invalidate their fast. The person was already in a state of fasting and should have taken the proper steps to verify the time before taking the action of breaking the fast.
However, if a person is at suhoor time and has not yet started fasting and makes the false assumption that fajr time has not come in yet and continues eating, their fast is valid. The mistake was made when they were in the current state of not fasting and their poor judgement consisted of them continuing to be in that current state.