Hi Alan,
It is one feature named Related Records Filtering
https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/customize/special-field-properties-legacy?view=op-9-1#lookup-field-properties
This feature allows you to filter records where the record you are looking up to is already related to the record you are looking up from.
A good example of this is the Primary Contact lookup on the Account table, where you can only select Contacts where the Company Name matches the Account you are looking up from.(This is the one you show in the picture)
To enable this you need to access the classic form editor, go Settings > Customizations > Customize the system > Entities to open the form of the entity, then clicking tone lookup field to open 'Field Properties' dialog.

Note: 'Users can turn off filter' option must be checked, Otherwise you will not see the filter box shown on the dialog.