In integral form Ampere's law says that the line integral of a magnetic field of a closed path is equal to the current that passes through that enclosed path.
When we solve for a magnetic field we are solving for a magnetic field that is made up of only the enclosed current.
So if there is a current somewhere outside of the enclosed path it will contribute to the total magnetic field, however that is different than the magnetic field that is created solely from an enclosed current which is the magnetic field of ampere's law.