Many Muslims believe that what they are going to do is caused by what has already been written in Al-Lauhulmahfudz - they confuse 'causation' with 'association'. In truth what we have is association, not causation. What we do is not caused by what is written by Allah. Allah with His ultimate knowledge knew what we are going to do. He could easily have put the good-doers into Jannah and the evil-doers into the Hellfire. But Allah is Adil (Just) so He created us in this life as to test us which way to go. What we are going to do will match what has already been written but it's not a matter of causation - what we do is out of our own willingness and ability and we do have full responsibility on whatever choice we make.
Looking at guidance and misguidance, guidance (hidayah) is a gift (rahmah) from Allah. It is Allah who created us and gave us the mind so we can distinguish between right and wrong to a certain capacity. It is Allah who equipped us with fitrah to like the truth and good and to dislike the wrong and evil It is Allah who gave us the ability and power to do things and it is Allah who sent the Messenger with the Message to guide us in things, which are beyond the reach of our conception. So when it comes to guidance it is a bounty from Allah.
But when it comes to misguidance, it has to do with us. When we do bad deeds, it is from our own willingness and ability.
Those who turn away from guidance do so because they want to turn away, i.e. they choose not to be guided. They have been misguided because they are arrogant - they refuse to listen.
And so when they swerved from the right way, Allah let their hearts swerve from the truth.[Surah As-Saff (61): ayat 5]
Nevertheless there are people who have not received the Message of Islam/guidance at all or the Message has not reached them in the clearest form, i.e. it is incomplete or distorted. These people are called Ahlul Fatrah and will be excused and not be punished, even though there are misguided.