It is because of the difference in size. Basically, to keep the iPhone as small as it is but still add all the features, they chose to eliminate the headphone jack. As I understand things, at least with the X, they could have made the phone larger, which would have added larger bezels, or "shrunk" the battery. Shrunk is in quotes because it is likely it would have just caused the removal of one of the two batteries in the iPhone.
On the iPhone 7, it was caused by adding the taptic feedback engine; they couldn't add the taptic engine and keep the headphone jack without increasing the size of the 7 over the 6s, or putting in a much smaller battery.
Of course, with a MacBook, the space the headphone jack takes up is not an issue.