Archers are primarily defined by the use of a bow and arrow. A soldier can be an archer. A hunter can be an archer. An athlete can be an archer.
In fantasy settings, a ranger, as @cherrystark said, is defined by their wilderness survival skills. They forage, they track animals, they can build fires, etc. They are often very good hunters, so they may indeed use a bow and arrow, but are not restricted to that weapon alone, or even required to use it.
Basically, some rangers are also archers, and some archers can be rangers. But an archer is a person who shoots a bow and arrow, and a (fantasy) ranger is a wilderness survival expert.