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.