Peter knew that Ananias and Sapphira were guilty before he asked them in Acts 5. He asked anyway so they would have an opportunity to either repent or prove their guilty before multiple witnesses. They had witnessed the miracles that God performed through Peter and still blatantly lied about their house. Pride twisted their faith and made them believe they could hide from the Almighty just like Adam and Eve.

God created us with the ability to justify anything we want to believe. We are masters of self-deception. A determined atheist can maintain his disbelief even after witnessing the most earth-shaking miracles.