There are in general two types of editors, and their role is quite different.
First, you have the editors-in-chief or editors-in-charge. There is usually one of them for a journal, sometimes a small group (if the journal has dozens of issues a year). These "run" the journal, but are not responsible for the scientific quality of the papers. They can be scientists themselves, but quite often they are not active in science and their editorial job is a full-time.
Second, you have the communicating editors. There can be tens of them. Each of them is usually responsible for communicating the papers in some sub-field of the journal's field; so in a graph theory journal, you'll have someone for dealing with graph algorithms, someone for Ramsey theory, etc. These are supposed to be active scientists in their field since only then they know the right people to review the paper and they can have a good level of judgment over the paper's quality themselves.
So, the hiring process differs a lot. If a non-scientist is sought for, a standard competition will usually be held, the position announced through various means (mailing lists, job advert sites, LinkedIn, etc.). You can simply join the competition, send your CV and other required documents and hope.
On the other hand, if a specialist scientist is sought for, then usually what Stephan Kolassa describes is the case: the editor-in-chief will look for people based on the journal's experience with the people and ask them on a personal basis.
Remark: The terminology may differ from journal to journal, and also the actual situation may differ. Especially with small journals, even editor-in-chief need not to have it as a full-time job, and he can do research himself. It just depends.