Hitting is done for attention, from frustration, or is an expression of some negative feelings (fatigue or even hunger.) You can keep track in your mind when it tends to happen and try to anticipate this reaction, try to minimize the opportunity to hit (e.g. redirection to another toy/activity) or try to teach a toddler to deal with frustration in a healthier manner. The article I linked to below is from the American Academy of pediatrics. It discusses things I have often espoused here: teaching the child an emotional vocabulary (18 months is not too young to start), anticipation, redirection, time outs, etc.
My oldest child did not hit, but bit when he was a toddler. Like you, I tried explaining, gentle corrections, modelling behavior, etc. to no avail whatsoever. He was biting at home, he was biting at preschool, he was biting all the time. He stopped biting in one day; it was so dramatic, I remember it clearly many years later.
He didn't get what he wanted to play with at the neighbor child's house, so he bit the child. I was so embarrassed that without a word, I immediately scooped him up and rather dramatically walked to our home next door and sat him down. I said, "No bite!" and made him sit there doing nothing for a few minutes. He never bit again.
I don't know what it was about the situation that changed his behavior: my sudden, immediate removal from the situation, the surprise of seeing a strong emotional response in me, the drama of the whole thing... I truly don't know. I don't know if what I did scared him or impressed him (he didn't cry or withhold or become shy or anything during the time out or after.) I don't even know if it was the right thing to do (I kind of doubt it.) But that is what worked for us.
Good luck; hitting, biting, and other socially unacceptable behaviors are difficult - though very common - behaviors to deal with.
EFFECTIVE DISCIPLINE