The WB groups the countries - or rather the economies - according to GNI (see below)
For the current 2016 fiscal year, low-income economies are defined as those with a GNI per capita, calculated using the World Bank Atlas method, of $1,045 or less in 2014; middle-income economies are those with a GNI per capita of more than $1,045 but less than $12,736; high-income economies are those with a GNI per capita of $12,736 or more. Lower-middle-income and upper-middle-income economies are separated at a GNI per capita of $4,125.
The categories of the WB are based on economic indicators, mainly per capita income. According to this different categories are created. Indeed there are instances that countries try to keep in the lower categories as they can access grants and loans at better (cheaper) conditions.