I was using SPWeb.Groups to get all the groups in the web, but it was returning only 17 groups out of 100+ groups.

After some research I found that these 17 groups have some permissions to the site (like read, contribute.. etc), all missing groups do not have any permissions on the site (they are just created as group).

SPWeb.Groups returns only the groups that has some permissions.

If you want to display all groups (including the ones with out permissions), we need to use SPWeb.SiteGroups.