1 John 4:
14 And we have seen and testify that the Father has sent His Son to be the Savior of the world.
It begins with a collective "we".
15 If anyone confesses that Jesus is the Son of God, God abides in him, and he in God.
Then it is personalized individually. For each individual x, such that if x confesses ... .
God does not just abide in the collective but abides in x personally and individually. Each of us is connected to God through the indwelling spirit individually.
16 And we have come to know and believe the love that God has for us.
The collective "we" resumes. Then the number changes again.
God is love; whoever [singular] abides in love abides in God, and God in him.
It is individualized for the indwelling spiritual connection.
17 In this way, love has been perfected among us, so that we may have confidence on the day of judgment; for in this world we are just like Him.
It ends with the overall picture of the collective.
Why does 1 John 4:16 switch from the plural “we have come to know” to singular “and whoever abides”?
There is no Greek grammar rule against this practice. The switching shows the personalization of the abiding between me and God.