Both are {noun+の or verbal phrase X}ように{verb Y
}, ie to do Y in a way of X, do Y like or similar to X.
Most literally you could interpret all these sentences in such a way:
I (shall) act such that [in a way that] I remember
[I am wishing] In a way that the weather be clear tomorrow.
To teach in a way a teacher teaches.
The nuances follow quite intuitively.
"in a way such that it is nice tomorrow" starts to make sense once we add the implicit "I/We wish or hope in such a way" or "please act in such a way, {some deity}!".
ようにする, from its literal meaning, has become one standard expression for your goals.
Generalization (extended sense) and concretisation (restricting to one sense), as well as.metaphors are common in language, and I think it's not too hard to see what all these three sentences have got in common.