For two congruent matrices $S_1, S_2$, you get isomorphic Lie algebras. Since over an algebraically closed field (like $\mathbb C$), any two symmetric matrices of full rank are congruent, the choice here doesn't matter.
But if the base field is $\mathbb R$ as you write twice, symmetric matrices are up to congruence classified by their signature (Sylvester's Theorem), and the different definitions you have encountered give non-isomorphic Lie algebras: $S=I_n$ has signature $(n,0)$ and defines the compact form which is commonly denoted as the real Lie algebra $\mathfrak{so}_n$. On the other extreme, $S=\begin{pmatrix}
1&0&0\\
0&O&I_{k}\\
0&I_{k}&O
\end{pmatrix}$ for $n=2k+1$ (or $S=\begin{pmatrix}
O&I_{k}\\
I_{k}&O
\end{pmatrix}$ for $n=2k$) have signature $(k+1,k)$ (or $(k,k)$, respectively), and with them one defines the split real Lie algebras which are commonly denoted as something like $\mathfrak{so}_{k+1,k}$ (or $\mathfrak{so}_{k,k}$, respectively). For other signatures, there are more real Lie algebras, corresponding to the various indefinite orthogonal groups.
Note however that the complexifications of any of these, by what was said above for algebraically closed fields, become all isomorphic to each other. Maybe the confusion stems from some sources not carefully distinguishing between (non-isomorphic) real Lie algebras and their (isomorphic) complexification.
Added later: One should really think of these constructions not only in terms of matrices, but in terms of symmetric bilinear forms (equivalently, quadratic forms) which are, in one way or another, what defines these Lie algebras, or their corresponding Lie groups (as the transformations which leave that form invariant one way or another). That perspective makes it quite clear that congruence of matrices will give isomorphic Lie algebras, because it is nothing else but base change. Cf. also https://math.stackexchange.com/a/3489788/96384, "Step 2" in https://math.stackexchange.com/a/3708980/96384, and Let $gl_S(n,F) = \{x \in gl(n,F) : x^tS = -Sx \}$ and $T = P^tSP$. Show $gl_S(n,F) \cong gl_T(n,F)$.
Also, I would like to point out for future readers that in general, even non-congruent matrices can give rise to isomorphic Lie algebras: There is a "coarser" equivalence relation, namely "congruence up to scalars", which at least in many cases is actually equivalent to isomorphism of the corresponding Lie algebras. For example even over $\mathbb R$, the matrices $I_n$ and $-I_n$ are not congruent, but both give rise to the classical compact $\mathfrak{so}_n$: One can flip the number of $1$'s and $-1$'s in the signature, i.e. multiply $S$ with $-I_n$, and still get isomorphic Lie algebras. Cf. comments to $gl_S(n,F) \cong gl_T(n,F) \rightarrow T \cong S?$, and for very abstract context, https://math.stackexchange.com/a/3981832/96384.