Family A: marginal rate 20%, average rate 10%
Family B: marginal rate 40%, average rate 23%
The marginal tax rate is the rate paid on the last dollar of income; this would be whatever tax bracket the family is in. The average price is the total tax divided by the total revenue.
Family A:
total income $40,000: this includes $10,000 at 0%, $20,000 at 10% (tax of $2,000), and $10,000 at 20% (tax of $2,000). The last rate paid is 20% so that is the marginal rate; the total tax paid is $4,000, divide that by $40,000 total income, that is the average rate.
Family B:
total income $100,000: this includes $10,000 at 0%, $20,000 at 10% (tax of $2,000), $20,000 at 20% (tax of $4,000), $30,000 at 30% (tax of $9,000), and $20,000 at 40% (tax of $8,000). The last rate paid is 40% so that is the marginal rate; the total tax paid is $23,000, divide that by $100,000 total income, that is the average rate.