If you draw inside the axis environment, you can use the axis cs: for that. To show that it works for arbitrary functions, I've added a 'complex' function. Note that I added the clip=false option to the axis to prevent the marks from being clipped.
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usepackage{pgfplots}
\tikzset{
declare function={
% myslope2(\x) = 24 - \x*(24/48);
myslope(\x) = 8 - \x*(8/32);
mycomplexfunction(\x) = sin(60*pow(\x,1.2)) + 6;
},
}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{1}
\begin{tikzpicture}[scale=.9, transform shape]
\begin{axis}[ axis lines=center,axis line style={black, thick,-latex},
axis y line=left,axis x line=bottom,
tick style={line width=.04cm, color=black, line cap=round},
font=\normalsize,color=black,
xmin=0,xmax=64,
xtick={0,16,32},xticklabels={0,16,32},
ymin=0,ymax=16,
ytick={4,8},yticklabels={4,8},
tickwidth=.2cm,
xlabel={P}, xlabel style={right},
ylabel={M}, ylabel style={above},
xticklabel style={inner xsep=0cm, xshift=0cm,yshift=-.1cm},
yticklabel style={inner ysep=0cm,xshift=-.1cm,yshift=0cm},
samples=200,
clip=false]
\draw[ultra thick,blue] plot[samples at={0,16,32},mark=*,mark options={black}] (axis cs:\x,{myslope(\x)});
\draw[thick,black,densely dotted] (axis cs:0,{myslope(16)}) -- (axis cs:16,{myslope(16)}) node [black, xshift=.46cm, yshift=.05cm] {A} -- (axis cs:16,0);
\draw[thin,red] plot[domain=0.1:32,smooth,samples=200] (axis cs:\x,{mycomplexfunction(\x)});
\draw[thin,red,densely dotted] (axis cs:0,{mycomplexfunction(20)}) -- (axis cs:20,{mycomplexfunction(20)}) -- (axis cs:20,0);
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}
It looks like this:

For the example image you showed, you need the function myslope2(\x) = 24 - \x*(24/48);. Just add the samples in the same way as above.
Edit
As pointed out in the comments by @TorbjørnT, using \pgfplotset{compat=1.11} or higher lets the axis cs be the default coordinate system inside the axis from \draw commands. Also if you use \addplot instead of \draw plot, the markers are not clipped when they protrude outside the axis area, so you don't need the clip=false option anymore. \addplot has some additional advantages, e.g. adding legend entries with \addlegendentry{} as shown in the following example:
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\tikzset{
declare function={
% myslope2(\x) = 24 - \x*(24/48);
myslope(\x) = 8 - \x*(8/32);
mycomplexfunction(\x) = sin(60*pow(\x,1.3)) + 6;
},
}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{1}
\begin{tikzpicture}[scale=.9, transform shape]
\begin{axis}[
axis lines=center,
axis line style={black, thick,-latex},
axis y line=left,axis x line=bottom,
tick style={line width=.04cm, color=black, line cap=round},
font=\normalsize,
color=black,
xmin=0,
xmax=64,
xtick={0,16,32},
xticklabels={0,16,32},
ymin=0,
ymax=16,
ytick={4,8},
yticklabels={4,8},
tickwidth=.2cm,
xlabel={P},
xlabel style={right},
ylabel={M},
ylabel style={above},
xticklabel style={inner xsep=0cm, xshift=0cm,yshift=-.1cm},
yticklabel style={inner ysep=0cm,xshift=-.1cm,yshift=0cm},
samples=200
]
\addplot[ultra thick,blue,samples at={0,16,32},mark=*,mark options={black}] {myslope(x)};
\addlegendentry{Simple slope};
\draw[thick,black,densely dotted] (0,{myslope(16)}) -- (16,{myslope(16)}) node [black, xshift=.46cm, yshift=.05cm] {A} -- (16,0);
\addplot[thin,red,samples=200,smooth,domain=0:32] {mycomplexfunction(x)};
\addlegendentry{Complex function};
\draw[thin,red,densely dotted] (0,{mycomplexfunction(20)}) -- (20,{mycomplexfunction(20)}) -- (20,0);
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}

\pgfplotsset{compat=1.11}(or some higher version number), thenaxis cs:is default, and doesn't have to be given explicitly. And if you use\addplot[ultra thick,blue,samples at={0,16,32},mark=*,mark options={black}] {myslope(x)};instead of\draw plot, then the marks won't be clipped, so you don't needclip=false. – Torbjørn T. Jul 11 '18 at 09:01