Abraham's laugh was a laugh of joy, while Sarah's laugh was a laugh of contempt.
God looks at the heart or that is to say he looks at the underlying cause.
The heart in Christianity is believed to be the place where one's loyalty, belief, dedication, and so on is lodged.
All Scripture is quoted from the King James translation.
Matthew 12:35 A good man out of the good treasure of the heart bringeth forth good things: and an evil man out of the evil treasure bringeth forth evil things.
Matthew 13:15 For this people's heart is waxed gross, and their ears are dull of hearing, and their eyes they have closed; lest at any time they should see with their eyes, and hear with their ears, and should understand with their heart, and should be converted, and I should heal them.
Unless God understood the machinations of man's minds he would not be omniscient, and could not have known:
Genesis 15:4 through 6 And, behold, the word of the LORD came unto him, saying, This shall not be thine heir; but he that shall come forth out of thine own bowels shall be thine heir. 5 And he brought him forth abroad, and said, Look now toward heaven, and tell the stars, if thou be able to number them: and he said unto him, So shall thy seed be. 6 And he believed in the LORD; and he counted it to him for righteousness.