Restrain means to hold yourself back, which is exactly what you'd have to do if, after weeks of dieting, you found yourself face to face with a dessert case filled with pies, cakes, and cookies.
Restrain can also mean to restrict or hold back someone else, to prevent someone from doing what they're intending to do. Prison guards have to restrain a prisoner who is trying to attack one of his fellow inmates. That prisoner might even be put in handcuffs — a kind of restraint. You can restrain yourself, for example if you're watching a Broadway show and suddenly feel the urge to sing along. Your fellow audience members would be grateful for your restraint, especially if you've got a terrible voice.