Two officers were making their way upstairs when a knife-wielding man appeared