A police precinct is a geographical division, usually of a large city or municipality which is patrolled by police officers or in which police detectives investigate crimes committed within the precinct's borders.
In Castle, Beckett's team are based in the New York City Police Department's 12th Precinct. The Robbery Division is located downstairs from the Homicide Division where Beckett, Castle, and their colleagues work. Homicide is on the 4th floor, according to the elevator.
In Season 1 external shots of the building show the precinct as number 9 instead of number 12. Occasionally when we see footage of the outside of the building, 9th Precinct is clearly displayed. The building shown is the real-life NYPD 9th Precinct House at 321 East 5th Street, on the Lower East Side.
A new exterior for the 12th Precinct emerges mid-season 3. This is in real-life the exterior of the Los Angeles Theater Center on South Spring Street in LA (pictured).
The real 12th Precinct was abolished in 1916, and as of 1998, it was used as police storage. It was located at 205 Mulberry St. New York, New York. That address is just two blocks away from where Castle's loft is located (in real life) at 425 Broome Street.
However, in Crossfire, when Castle gets into a cab to go to the precinct, he gives the address as "24th and 7th" in Chelsea. Also, on a piece of 12th Precinct headed notepaper used as a prop in Little Girl Lost, and on Beckett's prop business cards, the address of the precinct is given as "1654 West 66th Street". This is a fictional address, as building numbers do not go that high on West 66th.
In Richard Castle's Nikki Heat series of books, Nikki and her team work out of the NYPD's 20th Precinct. That precinct exists in real life on the Upper West Side, at 120 West 82nd Street, and many of the murders Nikki investigates take place at identifiable Upper West Side locations.
In Den of Thieves, it emerges that Esposito's first assignment as a cop was to the fictional 54th Precinct, where he first met Tom Demming.