Why do some dying star form into a white dwarf, while others form into neutron stars or black holes?
It all depends upon the size and mass of a Star.
It all depends upon the mass of a Star. Main sequence stars like our Sun will burn their fuel for about 9-10 Billion years before becoming a Redgiant. In this state they will burn up Helium to Carbon for the next few million years until they have no more Helium left to burn and are not dense enough to bun Carbon. At this time the Redgiant Sun will collapse on its core as there will be no fusion energy stopping the inward acting gravity of the Sun. The Sun will shed it's outer layers into interstellar space and transform itself into a White dwarf a cooler extremely dense Star about the Size of the Earth.
Stars bigger than our Sun the Super giants about 5-8 times the mass of the Sun will burn their fuel much more faster than our Sun and will also be dense enough to even burn Carbon to other elements, that too quickly until they have nothing else to burn and the Star will violently explode leaving behind a Neutron Star which when rotating quickly are called Pulsars.
Stars even bigger than Super Giants 10-15 times the mass of the SUn will burn their fuel the fastest and will be the densest stars. When they go Supernovae they will leave behind the most dense objects known A Black hole.