Modi continues to be a popular leader. His sincerity and commitment are not questioned even by the opposition. At the national level, he towers over all other netas. His eloquence is unmatched. The only doubt prior to elections was 'would all these qualities matter in a state election?'
Ultimately they mattered because other parties committed many mistakes.
1) Samajwadi Party imploded thanks to the family fight between Mulayam and Akhilesh. Akhilesh is the son of Mulayam's first wife. The second wife might have caused the estrangement between the father and son. Second-tier leaders in SP started taking sides and the party was vertically split.
2) Akhilesh's association with Congress created further belligerence from the father who was supported by Amar Singh , a Narada-type character who fishes in troubled waters.
3) Rahul Gandhi completely relied on Prashant Kishor, a strategist who is credited with shaping BJP victory in 2014 and JD victory in Bihar in 2016. This was resented by Congressmen in U P . Contrarily, Capt.Amarinder Singh of Congress shunned Kishor in Punjab.
4) Mayawati started wooing Muslim votes away from S P and Congress. Muslim votes got split to the advantage of BJP.
5) Some Muslim women voted for BJP, the only party that openly opposed triple talaq.
6) Priyanka Gandhi, the look-alike of Indira Gandhi, could not campaign because her son met with an accident and she was taking care of him.
7) Anti-incumbency also played its part. Akhilesh's government was at best patchy. Goondagiri was not controlled. Father and son split is rumoured to have been an artificial attempt to isolate the Akhilesh faction from thugs but the public saw through the gimmick.
8) BJP promised loan waiver for agriculturists.
So, in retrospect, the massive mandate for BJP is not surprising.