If a believer is to commit a sin and they get punished for it in the worldly life, do they get punished for it in the grave and whats to come afterwards?
If one receives a legal punishment in this life he/she won't expect an other in the hereafter (assuming he/she repents sincerely and Allah accepted it)... As stated in the hadith:
While we were in the company of Allah's Messenger (may peace be upon him) he said: Swear allegiance to me that you will not associate anything with Allah, that you will not commit adultery, that you will not steal, that you will not take any life which it is forbidden by Allah to take but with (legal) justification; and whoever among you fulfils it, his reward is with Allah and he who commits any such thing and is punished for it, that will be all atonement for it And if anyone commits anything and Allah conceals (his faultfls), his matter rests with Allah. He may forgive if He likes, and He may punish him if He likes. (sahih Muslim)
on the night of Al-'Aqaba pledge: Allah's Apostle said while a group of his companions were around him, "Swear allegiance to me for:
- Not to join anything in worship along with Allah.
- Not to steal.
- Not to commit illegal sexual intercourse.
- Not to kill your children.
- Not to accuse an innocent person (to spread such an accusation among people).
- Not to be disobedient (when ordered) to do good deed."
The Prophet (ﷺ) added: "Whoever among you fulfills his pledge will be rewarded by Allah. And whoever indulges in any one of them (except the ascription of partners to Allah) and gets the punishment in this world, that punishment will be an expiation for that sin. And if one indulges in any of them, and Allah conceals his sin, it is up to Him to forgive or punish him (in the Hereafter)." 'Ubada bin As-Samit added: "So we swore allegiance for these." (points to Allah's Apostle)
(different versions from sahih al-Bukhari 1, 2, 3, 4, 5, 6, Jami' at-Tirmdihi -with a not translated comment of Imam a-Shafi'i on it- and sunan an-Nasa'i)
This hadith clearly says if a Muslim received a punishment for a sin such as zina, theft etc. in this life, he won't be punished again for that in the hereafter!
Al-Haafiz said in al-Fath (1/6): “What we learn from this hadeeth is that the carrying out of the punishment is an expiation for the sin, even if the one on whom the hadd is carried out does not repent. This is the view of the majority. It was also said that he has to repent – this was stated by some of the Taabi’een.” (islamqa #6202)
The same may apply for those whom commit a sin which should be punished according shari'a and were not punished, but repented from it (24:71). As we know:
Indeed, Allah does not forgive association with Him, but He forgives what is less than that for whom He wills. ... (4:48)
In my first answer draft I was misinterpreting based on the verse of surat al-Kahf in the story of dhil-Qarnayn (18:87), but this is related to kufr not a punishment for a sinful act or crime which can be punished by hadd in this life!