noquit the instances you speak of is the result of money given to you by the institution you are a customer of.
A margin account is your broker allowing you to trade money you don't have. They assume the risk and they can force you to sell stock to cover the call.
The bank gives you money by mistake. It's their money, they can take it back.
Now, call your broker and ask them who funded your dividend. It is just that simple. Then report back here what you find out. That will put this whole issue to rest.