This paper is dedicated to investigating the undrained lateral capacity of rigid free-head rectangular/square piles in cohesive soil. The study utilizes the three-dimensional Finite Element Limit Analysis (FELA) framework to analyze and assess the pile's ability to withstand lateral loads. Both upper bound (UB) and lower bound (LB) FELA techniques are employed in the analysis process. The findings emphasize the importance of understanding the behavior and failure mechanisms exhibited by the surrounding soil around the pile. The analysis employs dimensionless approaches to obtain the normalized load factor, which represents the outcomes of the solution. The results obtained from the analysis demonstrate that the lateral load capacity of the soil is influenced by several key factors, including the pile's length-width ratio, the height-width ratio, the eccentricity of the lateral load, and the overburden stress where the discussion regarding the effects of all parameters is provided in the manuscript. The study also delves into the examination and understanding of the failure mechanisms exhibited by the soil in the context of lateral loaded piles. Based on the numerical outcome, the artificial neural network (ANN), which is one of soft-computing techniques, is utilized to establish a surrogate model for predicting the lateral capacity of rectangular piles. By considering these factors in the design process, engineers can make informed decisions that effectively optimize pile performance and ensure the long-term stability of structures.