First-order magnetic transition induced by structural transition in hexagonal structure