Well for starters those hands you used as examples, aren't coin flips. The first one, assuming both hands were suited, the AKs was ahead with about 63% chance to win. And the second the tens were ahead with about 70% change to win. So you got your money in with the best of it and variance just didn't go your way this time. That's unavoidable.
As for your questions, there is no way we could ever give you a specific answer to that question that works all the time. There are to many variables that come in to play that are different for every single hand. About the only real "rule" that you could come up with (and it is very flexible case by case as well) is you usually want a better hand to call an all-in with then you would push all in with. The big reason for that is if you are the one pushing all in you have two ways to win, having the best hand by the river or making the other guy fold right there. However, if you call the all in from someone else, you have to have the best hand by the river to win.