Let's use the current situation: Sanders and Bernie are the top 2 leaders for the DNC and it looks like Biden might win. Would Sanders be automatically given the nomination if Biden was declared unable to continue to run for health reasons?
Sanders would not be given the nomination. If no one wins a majority of the delegates going into the convention then it becomes a brokered convention. More specifically if, in the first round of voting, one candidate does not reach 50%+1 of the delegates then there is another round of voting.
In the first round delegates are pledged to the candidate hence MUST vote for him. In the second, and subsequent rounds, the delegates may vote for anyone of their choosing. In addition super delegates are able to vote as well.
Look up the 1924 Democratic National Convention to see an interesting example of how this has played out in the past.