Frictionally excited thermoelastic instability in viscoelastic and poroelastic media