You're looking at the wrong table, you need the Wealth by Level table in the DMG, page 135.
For a level 5 character, the expected wealth is 9000 gp. But this assumes 4 party members, you could get less or more if you have more or less characters in your party. But that can be a burden if your DM doesn't want to do math, and you could also argue that you wouldn't get more or less though, as perhaps the encounters would be stronger/weaker for parties of more/less characters. See below for further explanation.
That chart you mentioned in your question is the Wealth Comparisons table on page 54 of the DMG, but this is only one of 3 major tables to consider. The three are:
Treasure Values per Encounter (TPE herein, DMG pg 51)
Wealth Comparisons (WCT herein, DMG pg 54)
Wealth by Level (WBL herein, DMG pg 135)
It's important to note the assumptions of the WCT -- it assumes 13.33 encounters per level gained, and four characters per party (see underneath the table). The expected wealth gain of 4000 gp you quoted is actually how much a character should make going from level 5 to level 6, and if you look at the WBL table you'll see that the expected wealth of a level 5 character is 9000 gp, and 13000 gp for a level 6 character (a difference of 4000).
The expected wealth gain is meant to be a "net profit" value, whereas the treasure per character is meant to be a "gross income" value. On the way from level 5 to 6, you should get 5332 gp worth of treasure, but spend 1332 gp on things like scrolls, potions, etc, and be left with 4000 gp extra. The Treasure per character is calculated from the TPE table: at level 5, the expected value of treasure per encounter is 1600 gp. Multiply by 13.33 encounters and divide by 4 characters to get 5332 gp.