Is it possible to move past bad decisions made during PhD and hope for a bright future if I do a good job in postdoc? I completed my PhD in mechanical engineering last year. It took me 5.5 years to complete it. I already held a master's degree previously albeit in a different research area. The main reason was my inability to understand the topic, develop ideas and carry out focused work during the first 2 years of PhD.

I got disinterested in my topic/research area early on in my PhD. This was mainly because I had to self learn many advanced topics which were not taught in my university. That made me less sure about my knowledge.

However, post 3rd year, I worked hard, got interested in the topic and published 2 papers in decent journals.

In addition, I did very few TAs during my PhD because I was unfocused during my first few years and couldn't invest time in any other activities.

Now, I am pursuing a postdoc with my PhD supervisor on a different approach to my PhD project which is interesting and will help me secure better positions later. I plan to use this time to publish 4-5 papers.

Will the ghost of my past bad decisions made during PhD haunt me and affect my future even if I do a focused and productive job in my postdoc?
First of all, congratulations for your achievements! 

I did not a complete a PhD, not to mention a postdoc, but I had my own bad experiences during my academic and professional career.

From reading your question, it seems you have all conditions to succeed in this new stage of your life/career. Obviously, you had your low moments a few years ago, but you saw with your own eyes they can be overcome. I believe this could give you the extra confidence when facing obstacles later that you can spot them and know how to resolve them by yourself or with help from others.

Regarding obtaining future positions/jobs, I am confident PIs, universities and generally employers do no look that far in the past, but rather focus on the performance of people in recent years. In consequence, I believe you should keep a positive attitude and when the ghosts from the past appear realise they can be again defeated.