Are ford ranger body parts for a 4 cyl and v6 interchangeable?

I have a 2004 ford ranger 2.3. I went to a salvage yard to get a hood for my truck since mine was really bent. The guy had one hood left and he said it should work. I put it on my truck but it would not close. I slammed it down and still would not close. The shape looks like it belongs to my truck but it just wouldn't close. All sales are final so i couldn't return the hood. I put the old hood back on and that one closes properly

Yes they should be.

You need to adjust the LATCH!

The hoods are interchangeable. Any time you put a new body part on you have to adjust it so it fits. If it is too difficult for you, put the new hood in the back, and have a body shop do it.