Your situation is typically referred to an A-B-A play, and since A ends up with the ball there is no reason for wholesale teams to change out so the play clock is reset to 40.
However a K-R-K play is different. K would become A and R would become B. This would require a wholesale change out of players so play clock is 25.
There are a few play clock variations floating around so I would encourage you to get your information from your Individual State Rules Interpreter