Brooklyn/Kings County, Staten Island/Richmond County and Queens were all separate boroughs until 1898 when it was absorbed into NYC. Most powers have been centralized to N.Y.C. council but overlap still exists.
Not sure when Bronx was added, I think same year.
New York City, New York County and Manhattan Island have been identical since colonial times.
In 1885(? - somewhere around that time, anyways), the Southern tip of Westchester County (the modern South Bronx) was added to NYC and to NY County.
In 1898, Greater New York was formed, to consist of 5 Boroughs:
Manhattan (the old, pre-1885 NYC)
Richmond (Richmond County; the borough was renamed Staten Island not so long ago)
Brooklyn (the entire old Kings County, not just the former city of Brooklyn)
Queens (only part of the old Queens County. The remainder was organized as Nassau County.) All these were identical with Counties of the same size.
Bronx (the area added to New York county, plus an additional bit of Westchester County.) Bronx County was only created in 1910(?) - until then Bronx borough was partly in New York county, partly in Westchester county.