\documentclass[crop,tikz,convert=pdf2svg]{standalone}

% Tikz settings optimized for causal graphs.
\usetikzlibrary{shapes,decorations,arrows,calc,arrows.meta,fit,positioning}
\tikzset{
    -Latex,auto,node distance =1 cm and 1 cm, semithick ,
    state/.style ={ellipse, draw, minimum width = 0.7 cm},
    point/.style = {circle, draw, inner sep=0.04cm,fill,node contents={}},
    bidirected/.style={Latex-Latex,dashed},
    el/.style = {inner sep=2pt, align=left, sloped}
}

\begin{document}

% The graph
\begin{tikzpicture}
    \node[state] (p) at (0,2) {$S$};
    \node[state,rectangle] (k) at (-1.5,1) {$K$};
    \node[state] (x) at (0,0) {$L$};
    \node[state] (y) at (1.5,0) {$M$};

    \path (x) edge (y);
    \path (p) edge (k);
    \path[bidirected] (p) edge[bend left=20] (y);
    \path[bidirected] (p) edge[bend left=20] (x);
    \path[bidirected] (k) edge[bend left=20] (y);

    \path (k) edge (x);

    \node[draw=blue,dotted,fit=(x) (y), inner sep=0.2cm] (machine) {};
    
\end{tikzpicture}

\end{document}