Farms require irrigation to work efficiently. Unirrigated farms lose 1 from their tile production.
Any farm built adjacent to fresh water is irrigated. Fresh water sources are rivers, lakes, and oases. You can see if a tile has fresh water by mousing over it; the information is displayed in the tooltip.
Before a civilization discovers Civil Service, it cannot build any unirrigated farm except for farms on food resource tiles (wheat, corn, and rice). So you will not see the penalty for unirrigated farms except on such tiles.
After Civil Service has been discovered, farms also spread irrigation, and civs can build farms on many more tiles. This capability is sometimes referred to as chain irrigation. Chain irrigation makes it possible to build a line of farms to irrigate areas that do not have direct adjacency to fresh water. Chain irrigation from foreign civilizations is allowed.
After discovering Biology, farms no longer require irrigation to be built, but they still produce less food if not irrigated. That is, you can build them on any flat tile, but you still need a chain of irrigation back to a fresh water source to get full food production.