A bystander stopped a man from sexually assaulting a woman soon after he allegedly committed a fatal stabbing outside a shopping centre, police say.