A tense question about the use of modal verbs in the Harry Potter series

The second half of the second example isn't in the past tense at all. It's in the present tense because it's reporting Dursley's thought process at the time. The first part is in the past tense but that is merely placing the occurrence in the past


*What could he have been thinking of?*is the past tense of What can he be thinking of?

In "... yes,that would be it." would expresses probability and likelihood = "Yes that was probably it.

In It might have been Harvey, "might" expresses a lower probability than "may" or "could".

The tenses are in the past as they refer to actions in the past.