I'm trying to understand mathematics just like mathematicians do. So, I first realized that they use sets as the most foundational part to work with. But then books about set theory use the foundations of logic to define sets. So I need to start with logic. But the thing is that books about logic use already the concepts of set, natural numbers, the infinite, and at the end the same process of logic to define logic itself. It's rally confusing and I don't know how to deal with it. I appreciate your comments, suggestions, and everything related to this.
(This started as a comment, but grew out of control.)
Talking as a sort-of set-theorist, I have to say that while many mathematicians speak about sets and use sets in their work, their knowledge of set-theory is often rudimentary, at best.
Similarly, my knowledge of category theory is quite rudimentary, even though category theory has been proposed by (at least) some as an alternative foundation. Heck, my knowledge of logic is quite rudimentary, even though I spend my days in the Kurt Gödel Research Center for Mathematical Logic.
Set-theory as a (supposed) foundation for mathematics has nothing to do with being required knowledge. All it means is that if it needed to be done, we could build (virtually) all of current mathematics from the notions of set and membership. This has the philosophical advantage that the various areas of mathematics are not totally separated, and there is no issue with using a theorem from, say, complex analysis to prove a result in, say, number theory: at their base both areas are "really" talking about sets (please note the scare-quotes there), and there is a consistent translation from one area to the other. Of course, no-one in their right mind would actually state the Fundamental Theorem of Calculus using just sets and $\in$, much less formally prove it from ZFC.
So how do mathematicians deal with it? I would guess that many don't really care so much, and do their work happily. (The phrase "ignorance is bliss" comes to mind here.) Not knowing the formal statement of the Axiom Schema of Replacement does not keep one from applying it as needed. Similarly, the Deduction Theorem of first-order logic is a fairly natural result that mathematicians will apply several times a day without realising it. If one really had to develop a sophistication with logic and set-theory before working in algebraic topology, I would guess that the area would soon die as research would be delayed until mathematicians gained that knowledge.
My suggestion is as follows. If you find yourself really interested with mathematical logic, pursue it. If you find yourself really interested with set-theory, pursue it. But otherwise the introductions you see to these topics in the introductory chapters (or appendices) of texts in areas you actually are interested will usually be sufficient to start studying those areas.