Hi, Guest.
In the sentences "I like these ones" and "I like those ones", "these" and "those" function as adjectives/determiners, and "ones" -a pronoun- is used instead of repeating the word "glasses".
In "I like these" and I like "those", "these" and "those" are used as pronouns, so "ones" is not needed.
All four sentences are grammatically correct.
However, not long ago, I read in a dictionary that in American English and in formal British English "ones" is not used after "these/those":
"I prefer these glasses to those" instead of "I prefer these glasses to those ones".
I don't live either in the USA or in the UK, so I am not sure this still applies today.
Miriam