That depends.
Is the person conscious or not? It makes a huge difference. Does the priest actually have knowlege that the person is non-catholic?
If the person is not Catholic, and the priest knows this, then the priest should not do either of those sacraments, unless the person expresses a desire to become Catholic at that moment (and yes, the priest should ask). One might ask, why not? The answer is if the person still rejects the Catholic faith, then absolution would not be possible. A priest cannot reconcile someone to the Church who does not desire to be reconciled in the first place. In imminent danger of death, the barest minimum would suffice to receive someone into the Church. Baptism if necessary, goes without saying. In the case of a baptised non-Catholic, a simple nod of the head to the query “do you want to become Catholic” would be enough to receive the person into the Church, and then the priest could certainly absolve and anoint.
However, if the person is unconscious, and death is imminent, a priest would (indeed should) pronounce the short-form of the absolution–no matter what else. Whether or not that has any efficacy will depend upon the state of the patient’s conscience. One who wants to be absolved will be absolved. One who has no desire for absolution (yet cannot express that lack of desire) of course won’t be absolved. The priest would say the prayer anyway, in hope that the person desires forgiveness and absolution by being reconciled to the Church.
Extreme Unction would also depend upon whether or not the priest actually has the Oil of the Sick (OI) on his person. Most do not. I carry an emergency stock in the glove-compartment, as do many priests, but whether or not that is accessible at the moment wasn’t in the scenario (maybe that priest took a taxi).