An experiment is used to infer causality by manipulating independent variables and measuring their effects on dependent variables while controlling for extraneous variables. Key elements of an experiment include independent variables, dependent variables, test units, and controlling or accounting for extraneous variables. Experiments aim to establish internal validity by ensuring the independent variable is truly causing changes in the dependent variable, and external validity by generalizing results beyond the experimental conditions. Experimental designs include pre-experimental, quasi-experimental, true experimental, and statistical designs which aim to reduce threats to validity through techniques like randomization and controlling extraneous variables.