A cantata is a type of singing which is done accompanied by an instrument(s). By contrast, a cappella specifically refers to unaccompanied singing. The word(cantata) etymologically comes from the Italian word “cantare” which meant “to sing”. The word “cantata” was used mainly in the 17th and 18th century to describe music with religious words that were sung by a choir or by soloists or both, accompanied by instruments. The most famous cantatas are those by Johann Sebastian Bach. Nearly all his cantatas are sacred(written for church services). Very often he used Lutheran hymn tunes (chorales) for the first and last movements. In between there are movements for solo singers: recitatives and arias. A famous example is Bach's cantata no 80 which is based on the chorale “Ein feste Burg ist unser Gott(“A safe stronghold our God is still”). The whole work is about being safe in the hands of God. This is what the sermon would have been about. The congregation would join in singing the chorale towards the end of the cantata.
Other composers, such as Alessandro Scarlatti (1660-1725) wrote cantatas which were secular(not religious). The word “cantata” has also been used in the 20th century by composers such as Igor Stravinsky (1882-1971) and Benjamin Britten (1913-1976).
Thus the term came to apply to any and all forms of accompanied songs.