first see docs:
https://learn.microsoft.com/en-us/aspnet/core/blazor/components/lifecycle?view=aspnetcore-7.0
the blazer lifecycle, is really two stages.
stage 1, build the render tree.(a type of virtual dom) the renderer tree is generated by components adding/modifiying other component to the tree during their render. at render the parameters are passed to the component, and the component return its children components. if not already on the tree, they will be added, else they will be rendered with the parameters.
if a component is added to the tree, rather than just its parameter changed, this is called initialized by blazor (often call mounted in virtual dom libraries).
stage 2. the render tree update the browser dom. in the case of blazor server, the tree updates are sent to the client, and the client does this update.
some method have sync and async versions. use async if the code needs to use an await.
read and reread until you have a good grasp of the razor component tree. components are just a container of other components a presentation of a dom element. task for instance a <select> it has <option> children. so it represents a dom element and children dom elements.
when you want to modify the browsers html. you update the tree component that represents the desired html. as a tree render will will pre-render all components in the tree, the render method should be as fast as possible. the render can stop on leaves, when it hits a dom components whose parameters have not changed since the last render. you use parameter changes to cause a component to pre-render and produce new html.
BuildRenderTree - used by your component when you want to manually build the tree, rather than using the razor parser. as you asked this question, you do not understand the render tree enough to use.
InvokeAsync, StateHasChanged - used to notify the state has changed and the tree must pre-render. the method used depends on the caller. this must be execute on the UI thread. Invoke is used by non UI callbacks, StateHasChanged is used by by components. this is mostly used by event handlers.
OnAfterRender, OnAfterRenderAsync - called after the component has been rendered to the dom. JavaScript interop can now access the rendered dom element.
OnInitialized, OnInitializedAsync - called when a component is added to the tree, but before render. this will only be called once per component instance. but if a component is removed, then later added it will be a new instance. generally used to get initial values outside of parameters. you should always prefer parameters to external state. often used to set initial variable values.
OnParametersSet, OnParametersSetAsync - an event fired before render when a parameter (state) has been changed. this is handy place to detect if parameters have changed and can be used to trigger expensive operations effected by state.
SetParametersAsync - is called by the parent component to set its child components state. generally you would used to override binding expressions (mapping parametera to the parameter view). advanced use - beyond your pay grade
ShouldRender - called before render, and allows a component to not render (use current tree children and their properties). use this if you want to cache the output of your component.