It sounds to me as if you have had some backpoor luck with those roles. I don't believe you should put it down solely to your poor behaviour, or something lacking in yourself. People get fired all the time and often there is nothing they could have done differently.
That said, I think it would be helpful to focus on what your responsibilities are as a software developer/engineer, so I will outline them below:
- To understand the requirements. You need to understand what your manager or other stakeholders are asking you to deliver. If you do not understand then it is your responsibility to communicate this. If the requirements are not complete enough for you to move forward with 100% certainty, it is your responsibility to communicate any assumptions you are making to your managers/stakeholders in order to move forward.
- To be aware of deadlines. As a software developer it is your responsibility to be aware of all milestone and deadline dates for all your deliveries. If you are unaware of your deadlines, communicate this to your manager. If they are not prepared to give you a deadline, then communicate a commitment date to them which represents when you think you will be able to meet the requirement. At any time, for any reason, you think you will not meet a deadline, communicate this immediately to your manager, along with your new commitment date, and the reasons for this.
That's basically it. As a software developer you basically have 2 responsibilities; know what you are doing, and know when you have to do it by. If you can do this, then hopefully you will be able to hold onto your future jobs.
You will also notice I used the word communicate about 10 times in this answer :)