One important detail that may not be clear from the answer above is that the default form of matching in the matchit package (and in much of the scholarly literature in any field) is to use a propensity score that estimates, for each observation, the probability of assignment to treatment given some set of pre-treatment covariates using logistic regression.
While the default one-to-one nearest neighbor propensity score matching method in matchit will select the control observation with the smallest distance to a given treated observation, the resulting matched data is not paired in the way that the questioner imagines. The logit-based propensity score method collapses the multidimensional pre-treatment data to a unidimensional zero to one scale and identifies the appropriate control(s) for the treated observations. The end result is generally treated and control groups with greater overlap in their propensity scores but it is possible for a treated and a control unit to have propensity scores that are relatively far apart if, at that stage of the matching, a far away control has the shortest distance to the treated observation in question (this assumes matching without replacement or replace=FALSE in matchit syntax).
As a result, there is no guarantee with the default settings of
matchit(method="nearest", distance="logit") that a matched cohort will be produced in which each treated unit is closely paired with a specific control unit. If one uses the caliper feature of matchit (e.g., caliper=.1), then the matched treated and control units will always be within the caliper's distance of each other, more closely approximating a paired cohort.
When matchit has distance set to
'mahalanobis', not only is the distance calculation different but it operates with something like the caliper so that pairs of treated and control units are plausibly proximate. Hence the use of
distance='mahalanobis' above works to create a matched cohort of treated and control observations.
To see a visual representation of how nearest neighbor matching differs when distance calculated via logit vs via mahalanobis distance, see these slides from Gary King, one of the co-authors of the matchit package: