Four people believed to be homeless were stabbed, and two of them killed, in a spate of attacks that the New York police said could be related.