Sharepoint - How can I count Document library in Sites(SPWeb) Level?

No need for looping , just get the library at a specific site based on the base type equal to DocumentLibrary then get count of collection as the following :

using(SPSite site = new SPSite("https://yoursiteURL"))
{
  using (SPWeb web = site.OpenWeb())
  {   

    SPListCollection libcol = Web.GetListsOfType(SPBaseType.DocumentLibrary);
    libcol.Count;
  }
}

You can try this- as bellow

using(SPSite oSite = new SPSite("https://server/site"))
{
  using (SPWeb oWeb = oSite.OpenWeb())
  {
      SPListCollection docLibraryColl = oWeb.GetListsOfType(SPBaseType.DocumentLibrary);

      docLibraryColl.Count;
  }
}

Click Here & Here for reference.

Hope this will help you!


Get the document library count using LINQ:

    SPSite site = new SPSite("siteURL");
    SPWeb web = site.OpenWeb();

    var totalDocLibrary = (from SPList lst in web.Lists
                          where (lst.BaseType.Equals(SPBaseType.DocumentLibrary) && !lst.Hidden) 
                          select lst).Count();