The simple answer is buildings attenuate the signals the GPS receiver need to operate.
Each GPS satellite transmits data on two frequencies,(1575.42 Mhz) and (1227.60 MHz). Both frequencies are in the microwave range frequency spectrum. Building and other things attenuate these signals.
The GPS receiver in your Android device receives information from satellites to determine where it is located. The signal from the satellites are not a very strong signals depending on how far away a satellite might be.
Outside, under a clear sky most GPS receivers works great. Inside a frame house, the GPS receiver may also work well receiving signals. Inside a steel framed building, like an apartment building or school, the GPS receiver may not receive the transmitted signals at all or poorly. Likewise, during rain, under wet trees or in a canyon of buildings in a city where the path from the GPS to the satellites might be obscured by buildings Microwave signals have limited ability to penetrate these obstacles. Building walls etc. attenuate the signals broadcast from the satellites.
Some GPS receivers work well inside buildings, other's do not.Those that have more sensitive receivers or multiple receive channels have a better chance of working in a building.
For comparison, cell phones usually operate in the 800 Mhz or 1900 Mhz radio bands. These phones are also microwave radios. Sometimes it is not possible to use a cell phone in some buildings (unless near a window) and the user can obtain strong signals from the cell phone tower.