It finds any instances of two or more consecutive spaces and replaces it with one single space.
A breakdown:
{2,}
: matches any instances of two or more consecutive spaces.g
: modifier that specifies a global match. So all matches are found (not just the first).