As a side note - AActor::GetComponents templated on a component type. In case you need only one type of components you can write a much shorter version of your code:
TArray<UStaticMeshComponent*> comps;
hitActor->GetComponents(comps);
for (auto StaticMeshComponent : comps)
{
StaticMeshComponent->SetMaterial(0, redMatDynamic);
uIntersectedActorSMC = StaticMeshComponent;
isGraySet = false;
}