You can plant crops on dirt in any of your settlements. You don't have to worry about their growth or watering them. Just assign a settler to tend to them and they'll start producing food. You can harvest these crops whenever you visit a workshop. As long as a settler is tending to the crops, they'll bear fruit continuously. To know if the crop has an assigned settler tending to it, highlight it and if the required resource on the right side of the screen is red, that means it's unassigned.
During an attack, these crops maybe damaged so you have to repair them before they can produce anything again