ProfilingSampler.Get<TEnum> is not available in Release builds and intentionally returns null when used in non-development builds.
The same applies to RenderGraphProfilingScope.
To avoid any issues you can wrap Profiling code in the preprocessor directives.
#if DEVELOPMENT_BUILD || UNITY_EDITOR
//code
#endif