Can someone explain the Electronic Handbrake to me.

I haven't owned the car long enough or used it often enough to suss it out yet. I know how to work it but why does it sometimes release itself when pulling away in gear and other times it doesn't?

Like I said above I have not used the car enough yet to discover or work it out so I'm hoping someone on here can clear it up for me.

Cheers,

Lee.