I'm a manager within a global tech consulting firm and I estimate projects and write offers as part of my job:
Some really good advice on this thread already, but let me briefly summarise my POV:
First and foremost, not having written contracts is a no-no. You need to have a formal agreement on a whole range of issues, most of which have already been mentioned. Scope, compensation, change processes, liability, client's obligations towards your firm (and some definition of what happens when they're not met), assumptions (and what happens of they're not met) ...
Secondly, your compensation model needs to fit the type of work you do. If your scope is fuzzy (or, worse, entirely unclear) you stand roughly a snowball's chance in hell of not making losses if you're going with a fixed price. In this case, you're a lot safer with a time & materials approach. Understandably, clients tend not to prefer these unless you have an established relationship and they trust you not to waste their money, though. There are some very interesting mixed models, too, though. Google agile contracts - I've recently delivered a project on a model that set prices on a performance basis. The client lives it and it incentivised the team to do better.
Thirdly, your estimating seems way off the mark. That's a very common problem in a lot of IT projects, but there are ways and means of improving the situation. I suspect that your most pressing issue may again be that you're unclear on scope. You can't possibly know how much effort something requires if you can't properly define what is and isn't part of said something. Also, as PP have stated, developers always underestimate. Personally, I use a method based on back data of actuals from years worth of projects to apply factors to any estimates. I learned this from my ex-boss and it works miracles. To be frank, there's a good deal of art rather than science involved in estimating - in that you have to somehow approximate relevant context in addition to simply being able to forecast the raw amount of work that goes into a given task.
Then, forecasting and project controlling: you shouldn't find yourself in a situation where you're surprised by unexpected extra efforts or delays. If you set up good controlling and reporting you should be able to anticipate these and pro-actively work to limit impact.
And, finally, none of this is going to make a difference if you can't assert yourself. You have to protect your scope and your T&C as though it meant your life. Yes, doing something or other 'extra' is a good relationship builder - but you've got to be in a position to pick a something that won't break your back.
I could go on forever (and I do, at times, in that I teach internal project management courses). This is all very high level stuff right here. My best advice, OP, is to take thee to a bookshop and buy some PM educational books. Don't limit yourself to just one methodology either but read what each of them has to say so that you can assess what fits your client projects' circumstances.