How should we know the main aim of openings?


depending on the opening you're learning, you can try to learn themes in the opening rather than specific moves. For example in looking at the Ruy Lopez for white, obviously you want to remember that a main idea is to expand in the center with c3 d4, but also side ideas like that a well timed a4 can often destabilize blacks queenside, that your b1 knight may often like to route to g3 via Nd2 -> Nf1 if the position is closed, and that the f5 square is often very useful if you are looking for a kingside attack.
If you can pick out a few themes like this you notice in many of the lines, even if you don't necessarily memorize the line, you always have a couple of first candidate choices that'll probably be good to look at when you're lost.