Could you please explain me the difference between work AT smth and work ON smth?

And what the difference between these two sentences?

You have to work AT a marriage
You have to work ON a marriage

Thank you.