Countless factors influence composition, and many are discussed on this website. However, the largest single consideration is the "eye" of the photographer. Well composed images rarely arise purely from the application of "rules". Amateur photographic societies rightly introduce their members to the usual range of compositional guidelines, although some are probably also guilty of allowing their competition judges to use the same guidelines as hard rules.
In the literary world writers used to be taught to avoid split infinitives - "to boldly go" being the classic example! - where the adverb "boldly" splits the infinitive form of the verb "to go". This is quite logical since "to go" has a meaning, but "to boldly" does not! However, "to boldly go" serves its intended purpose admirably and is an example of how breaking the rules of language can work very well. A well-known writer once said that split infinitives should be avoided until the author understands them! The same advice is arguably applicable to photography and photographers. Avoid offending the composition guidelines until you understand them! Don't abuse them as a consequence of ignorance - do it with knowledge and understanding.
One more explanatory example is perhaps worth including. In the world of photographic distinctions, usually awarded by prominent, national or international photographic societies, three levels of achievement are generally recognized. These are typically known as Licentiateship, Associateship and Fellowship, or other comparable names. Licentiateship is awarded for basic skill and competence, Associateship for a higher standard of competence and creative ability in a particular field of work, and Fellowship for excellence and distinguished ability. These standards have been summarized as "Care", "Flair" and "Dare" respectively. The Licentiateship applicant must demonstrate that care has been taken in creating the images, and the work of the Associateship candidate must show flair in a particular field. The Fellowship is characterized as "Dare" because aspirants are assumed to understand all the rules and are allowed, even expected, to break them knowingly to produce stunning results!
The principle of "Dare" can and should be applied to composition but, it must be emphasized, only with knowledge and understanding. It is important to experiment with all sorts of ideas and rely on a well trained eye to know whether the resulting images work or not. A photographer who cannot recognize whether an image works, despite it offending composition guidelines, is arguably safer adhering to the established principles. Nevertheless, some of the best images are created outside the composition rules so often quoted in photographic societies.
Never be afraid to experiment or try new angles and ideas. The arrival of digital cameras has removed the worry about film processing costs, and leaves us free to shoot dozens or hundreds of shots. Most can be deleted later when it is seen that they were unsuccessful, but among them there may be a few jewels. A word of warning is also appropriate here. Do not experiment to the point where trial and error is the only technique. This is a hopeless approach and will rarely, if ever, produce worthwhile images. Experiment instead around a central idea and with certain types of compositions or image in mind. Try lots of small variations on a theme. Try emphasizing or over-using compositional elements that seem strong in a particular case. You never know until the image appears in the viewfinder or on a computer screen!
A good photographer works in such ways all the time. He or she seeks out the story or image and then works around it trying various approaches, viewpoints and compositions. The eye of an experienced photographer is so well trained that the hair on the back of the neck will stand up as an exceptional images forms in the viewfinder. The photographer may not be able to put into words how the quality of the image was recognized, but will have known without doubt that success had almost certainly been achieved as the shutter was released.