I've had teammates do this in the past, and it's frustrating. How can I prevent it from happening again, and should I approach my manager about it? How do I frame that conversation if so?
A good (related) question is here.
My big piece of advice here is to focus on making regular updates about your work, so you have a paper trail of your work, and (importantly) when it happened. With your manager, I'd recommend having an even more detailed "work diary" where you share the highlights of what you did each week, so they should have a lot of awareness on what you're working on.
If the credit-claiming is serious enough to bring up with the manager, I'd phrase more as "I want to ensure that anyone who has questions can quickly get the help they need, so it's bad for the team if the other person continues to claim credit for the work." Phrase it in terms of benefit for the team rather than benefit for you.