Characterizations of bilocality and $n$-locality of correlation tensors