Lets just get the circumstances in which this scene took place
Jon decides to travel beyond the Wall and capture a wight in order to
convince Cersei for a temporary alliance. But during this expedition,
the white walkers surround Jon and the others which is when Danerys
had to rescue them.
Now what you're asking is why the dragons or anyone didn't try killing the Night King. Here's why
Why Jon and the ones on land didn't try killing the King ?
They didn't have the means or the numbers to tackle the king, white walkers and the wights head on. And to even try would be foolish since they(Jon and the ones on land) would be crushed in seconds. To take the Night King, they would have to take on the entire army, (which is why they were forming an alliance with Cercei since they need the big numbers).
The goal for the day was to go get a single wight and no one was prepared for a battle.
Why Dany and her dragons didn't try killing the King ?
To Dany this was a Rescue mission, not an attack mission. She could have tried to kill the Night King, but her goal was to rescue Jon and the others. Killing the king is no mean feat even with three dragons with no thought out plan. That would put either her and the dragons at risk or Jon and the others at risk.
So finally the take away is that they were on an expedition and a rescue mission with a flight stance rather than a fight stance. If they got out alive, that information with a solid plan would work in their favour than them ending up killing themselves in the process. To try something as big as killing the Night King without a plan or preparedness might have resulted in unnecessary loss of the members most vital to this movement (Jon, Danerys, the dragons) which would be a bad move which is why they didn't attack the Night King right away