At least four people have been killed and buildings have collapsed after Taiwan was struck by its most powerful earthquake in 25 years.