Ananias and Sapphira in Acts chapter 5 were killed by God because they specifically lied to the apostles and therefore to the Holy Spirit (Acts 5:3). What they did was sell their land for a certain price and then kept some of the money. Their lie was saying that they had given all the money they had received for the sale of the property when in reality they hadn’t. Therefore, their judgment was swift.
But, we must remember that God is not obligated to forgive anyone. His forgiveness is always based on the work of Christ, and those who would openly and directly rebel against God and his goodness, as Ananias and Sapphira did, rightly deserve the judgment of God.
Finally, it does not mean that they lost their salvation if they were saved. They were judged. Likewise, we must take our integrity before God and people very seriously and do not present yourself as more loving and giving than you really are. That would be the sin of hypocrisy.