An affidavit is a legal document in which you swear to tell the truth. In a court, everything has to be sworn to in order to ensure that everything is even and fair. You might also sign one to indicate what you saw because you are not going to be in court yourself.
An affidavit is a statement that is under oath, with the signature of the person who has made the statement, and notarized with a seal. Affidavits are generally not admissible in court, considered hearsay, with few exceptions.