why does ammonia reacts with acid?

Because NH3 is a base. Acids react with bases (among other things).