There are several aspects to the Also Purchased ...
That code blocks the Also Purchased from showing on the product _info when in the products of those categories ...
To block Products from those categories from showing on other categories in the Also Purchased but still let the Also Purchased to show, you need to customize the code in:
and change the code to include the code in RED:
DEFINE('SQL_ALSO_PURCHASED', "select p.products_id, p.products_image
from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, "
. TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p
where opa.products_id = '%s'
and opa.orders_id = opb.orders_id
and opb.products_id != '%s'
and opb.products_id = p.products_id
and opb.orders_id = o.orders_id
and p.products_status = 1
and master_categories_id NOT IN (71, 72, 75, 76)
group by p.products_id
order by o.date_purchased desc
limit " . MAX_DISPLAY_ALSO_PURCHASED);