Algebraic varieties characterizing matroids and oriented matroids