PersonB has to attribute PersonA and, if possible, provide a link to PersonA’s work. In the typical case, PersonC would just follow this link and use PersonA’s work directly. But let’s assume this is not possible (e.g., because PersonA’s site is down).
If PersonB has modified PersonA’s work, PersonB has to state this. So unless PersonC finds such a statement, it can be assumed that no modifications were made.
Without modifications: PersonC takes PersonA’s work that is included in PersonB’s work. PersonC has to attribute PersonA (and not PersonB).
With modifications: The license CC BY doesn’t require PersonB to license their work under CC BY, too. So depending on PersonB’s license choice (or choice not to use any license), it could be the case that PersonC is not allowed to use PersonA’s work that got modified by PersonB. In case PersonB chooses to use CC BY, too, PersonC has to attribute both, PersonA and PersonB.
For the license CC BY-SA, it works the same in case no modifications were done. In case PersonB modified PersonA’s work, PersonB has to license it under CC BY-SA, too, so PersonC has the right to use Person B’s work (based on PersonA’s work), and PersonC has to attribute both.
tl;dr: You attribute who has created or modified the work, not who has distributed it.
See also the CC FAQ Do I need to be aware of anything else when providing attribution?
[…] Additionally, when you are using a work that is an adaptation of one or more pre-existing works, you may need to give credit to the creator(s) of the pre-existing work(s), in addition to giving credit to the creator of the adaptation.