Your question has several parts:
(i) How do you know that you defined the right Homomorphism?
This is obtained with experience. If you want to formally prove your answer, it is usually done by induction on the length of words on the language.

(ii)Can we have a situation for a language L, a word w and a homomorphism h such that w is not in L but h(w) is in h(L)?
The answer is yes! As an example take any non-empty L and any w and define the empty homomorphism.