Nearly 2,000 people who died were “definitely” or “probably” infected while in hospital, figures reveal.